xUnit global setup / teardown [migrated]
Posted
by
Codism
on Programmers
See other posts from Programmers
or by Codism
Published on 2012-10-19T14:22:30Z
Indexed on
2012/10/19
17:17 UTC
Read the original article
Hit count: 211
xunit
I need to run some code before any test is executed and also some code after all tests are done. I thought there must be some attributes or marker interface to indicate the global initialization and termination code but couldn't find them.
Alternatively, if I can invoke xUnit programmatically, I can also achieve what I want to do by the following code:
... Main(string[] args) {
try {
MyGlobalSetup();
RunAllTests(); // What goes into this method?
}
finally {
MyGlobalTeardown();
}
}
Can anyone provide me some hint about how to declaratively or programmally run some global setup/teardown code?
Thanks
© Programmers or respective owner